package com.szzg10.thinking.chapter11;

import java.awt.DisplayMode;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeSet;

public class CrossContainerInteration {

	public static void main(String[] args) {
		List<Pet> arrayList = new ArrayList<Pet>();
		arrayList.add(new Rat());
		arrayList.add(new Manx());
		arrayList.add(new Cymric());
		arrayList.add(new Mutt());
		arrayList.add(new Pug());
		arrayList.add(new Cymric());
		arrayList.add(new Rat());
		arrayList.add(new Manx());
		arrayList.add(new Cymric());
		arrayList.add(new Mutt());
		arrayList.add(new Pug());
		arrayList.add(new Cymric());
		
		LinkedList<Pet> linkedList = new LinkedList<Pet>(arrayList);
		HashSet<Pet> hashSet = new HashSet<Pet>(arrayList);
		TreeSet<Pet> treeSet = new TreeSet<Pet>(arrayList);
		
		display(arrayList.iterator());
		display(linkedList.iterator());
		display(hashSet.iterator());
		display(treeSet.iterator());
	}
	
	private static void display(Iterator<Pet> iterator) {
		while(iterator.hasNext()) {
			System.out.println(iterator.next());
		}
		System.out.println();
	}
}
